function request(method, url, data = {}, header = {}) {
    return new Promise((resolve, reject) => {
        wx.request({
            method,
            url,
            data,
            header,
            success(res) {
                resolve(res)
            },
            fail(err) {
                reject(err)
            }
        })
    })
}

request.get = (url, data = {}, header = {}) => request('get', url, data, header)
request.post = (url, data = {}, header = {}) => request('post', url, data, header)
request.head = (url, data = {}, header = {}) => request('head', url, data, header)
request.delete = (url, data = {}, header = {}) => request('delete', url, data, header)
request.put = (url, data = {}, header = {}) => request('put', url, data, header)

export default request
